﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using com.tdb.foundation;
using Script;
using Script.Function.Posion.Data;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class CardItemView : MonoBehaviour, IDragHandler
{
	[SerializeField]
	private Text _miniNumber, _numer;
	[SerializeField]
	private GameObject _posionIcon;
	
	[HideInInspector]
	public RectTransform RectTrans;
	/// <summary>
	/// 手牌堆中的位置序号
	/// </summary>
	private int _indexOfHandStack;
	/// <summary>
	/// 卡牌的数据
	/// </summary>
	private CardData _data;

	private void Start()
	{
		RectTrans = GetComponent<RectTransform>();
	}

	public void Init(int index, CardData data)
	{
		_indexOfHandStack = index;
		_data = data;
		string numberText = TextUtil.SetColorString(data.Number.ToString(), EnumConvert.CovertColorType2Color(data.Color));
		_miniNumber.text = numberText;
		_numer.text = numberText;
		if (data.Color == CardColorType.Posion)
		{
			_posionIcon.SetActive(true);
		}
	}
	
	
	public void OnDrag(PointerEventData eventData)
	{
		Debug.Log("Drag!!"+eventData.delta.x+" "+eventData.delta.y);
	}
}
